package com.intellagric.controller.agritech.controller;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.agritech.AgtResourceVo;
import com.intellagric.pojo.AgtResource;
import com.intellagric.service.agritech.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: cwq
 * @Date: 2019/2/22 22:16
 * @Description:
 */
@RequestMapping("/api/agt_resource")
@Controller
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    @RequestMapping("/add")
    @ResponseBody
    public ResponseMessage add(AgtResource resource) {
        return resourceService.addResource(resource);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return resourceService.deleteResource(id);
    }

    @RequestMapping("/edit")
    @ResponseBody
    public ResponseMessage edit(AgtResource resource) {
        return resourceService.editResource(resource);
    }

    @RequestMapping("/{id}")
    @ResponseBody
    public AgtResource get(@PathVariable String id) {
        return resourceService.getResourceById(id);
    }

    @RequestMapping("/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return resourceService.getResourceList();
    }

    @RequestMapping("/query")
    @ResponseBody
    public LayuiDataGridResult getListByVo(AgtResourceVo agtResourceVo, int page, int limit) {
        return resourceService.getResourceListByVo(agtResourceVo, page, limit);
    }

    @RequestMapping("/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return resourceService.getResourceByPage(page, limit);
    }
}
